home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dbase / lib19.zip / JPMOUSE.TXT < prev    next >
Text File  |  1992-05-25  |  11KB  |  224 lines

  1.                         JPmouse.zip, Version 1.0
  2.  
  3.         Program to manage the dBASE IV, Version 1.5, mouse.
  4. *------------------------------------------------------------------------
  5. *-- Programmer    : Jay Parsons, BORBBS Jparsons, CIS 70160,340
  6. *-- Date          : May 25, 1992
  7. *-- Notes         : A .bin file for the dBASE IV 1.5 mouse.
  8. *-- Revisions     : None
  9. *-- Usage         : See below.
  10. *-- Parameters    : a single character among six; see below.
  11. *------------------------------------------------------------------------
  12.  
  13.         This ZIP file contains the following files:
  14.  
  15.                 JPMOUSE.BIN, a dBASE IV 1.5 .bin to manage the mouse.
  16.                 JPMOUSE.ASM, its source code.
  17.                 README, this file.
  18.  
  19.         If you simply want to use the mouse in dBASE IV, Version 1.5,
  20. you don't need any of this.  This program is intended for those developers
  21. who wish to control the use of the mouse by their users.
  22.  
  23.                         Disclaimer
  24.  
  25.         The concepts used in this program were picked up through hurried
  26. experimentation and skimming the mostly unhelpful "Microsoft Mouse
  27. Programmer's Reference", Second Edition, Microsoft Press, 1991.  If the
  28. author's understanding is incorrect, which has happened, so is the
  29. program.  Advice of any errors in understanding, as well as of any bugs
  30. in the program, will be appreciated.
  31.                                     
  32.                         Use in general
  33.  
  34.         SETMOUSE.BIN must be loaded by the dBASE command LOAD Setmouse.
  35. Thereafter, it may be called with any of five one-character arguments that
  36. fall into three groups:
  37.  
  38.                    '?' to check for and reset mouse.  Does NOT show it
  39.  
  40.                    '+' to enable driver and show(?) mouse cursor
  41.                    '-' to disable driver and hide mouse cursor
  42.  
  43.                    'S' to show(?) cursor only
  44.                    'H' to hide cursor only
  45.  
  46.         Example:    LOAD JPmouse
  47.                     Ismouse = ( call("JPmouse","?") = 'T' )
  48.  
  49.         If no argument is given, the routine does nothing and returns
  50. nothing.  If an argument of at least one character is given, the routine
  51. does as follows:
  52.  
  53.         If the character is not in the set of permissible arguments ( lower-
  54. case is acceptable for letters ), it does nothing and returns 'F'.
  55.  
  56.         If the argument is '?', it checks for a mouse and enables it.
  57. It should not turn the mouse on, but it will be on if the .bin has been
  58. called from the dot prompt.  If called this way, the .bin returns either
  59. 'T' if a mouse driver is found or 'F'.
  60.  
  61.         In all other cases, it acts as though there is a mouse whether there
  62. is or not and returns 'T'.
  63.  
  64.         NOTE: As always in dBASE, a .bin can return a value only
  65.                 1) as the result of the call() function; or
  66.                 2) in a variable passed as an argument.
  67.         Consequently, do not use 'CALL JPmouse WITH "?"'.  The .bin
  68. will report the status to the argument buffer in which dBASE passed the
  69. character literal "?", but dBASE will have no way to access it.
  70. Use the call() function instead of the CALL command, or place the argument
  71. in a variable and CALL WITH that.
  72.  
  73.                         Anatomy of Mice
  74.  
  75.         Why all the complication?  Because dBASE itself turns the mouse on
  76. when issuing the dot prompt, because the mouse calls work in complex ways,
  77. and because turning the mouse on when it is on leaves immobile cursors,
  78. "mouse droppings", on the screen.
  79.  
  80.         The designers of the mouse software considered the possibility that
  81. a subroutine or function might want to hide the mouse cursor while doing
  82. video output, but that the mouse cursor might already have been hidden by
  83. some higher-level routine.  Accordingly, the mouse is designed so that
  84. any call to turn it off will do so, but a call to turn it on will take
  85. effect only if it was on before the last call to turn it off.  A counter
  86. that I call the "showmouse" counter is kept.  Turning the mouse on increases
  87. its value; turning it off decreases it.  The mouse comes on only when the
  88. showmouse counter is zero, after which no more calls to turn it on change
  89. the counter, although they do leave mouse turds.  A call to reset the mouse
  90. sets the counter to -1, hidden but ready to be shown by the next call.
  91.  
  92.                         Mouse driver functions
  93.  
  94.         Microsoft decreed that the mouse driver should inhabit interrupt
  95. 33h (51) and respond in fixed ways to calls to that interrupt.  While
  96. numerous functions are provided that this program does not use, these are
  97. the interrupt 33h functions it does use:
  98.  
  99.                 Function 0      Reset mouse
  100.                 Function 1      Show mouse
  101.                 Function 2      Hide mouse
  102.                 Function 1Fh    Disable mouse
  103.                 Function 20h    Enable mouse
  104.  
  105.         The reset function, Function 0, cleans up everything, returns the
  106. mouse to screen center, enables it, and sets the showmouse counter to -1.
  107.  
  108.         The show function increments the showmouse counter.  If it was -1,
  109. it becomes 0 and the mouse cursor appears.  If it was 0, mouse turds appear.
  110.  
  111.         The hide function decrements the showmouse counter, always hiding
  112. the mouse cursor since the counter is never greater than 0.
  113.  
  114.         The disable function stops the mouse driver from tracking what the
  115. mouse does, and the enable function starts it tracking again.  Neither has
  116. a direct effect on the mouse cursor.
  117.  
  118.         The arguments to JPmouse call these functions as follows:
  119.  
  120.                 '?' calls function 0.
  121.  
  122.                 '+' calls function 20h, then function 1.
  123.                 '-' calls function 1Fh, then function 2.
  124.  
  125.                 'S' calls function 1 only.
  126.                 'H' calls function 2 only.
  127.  
  128.                    Belt, Suspenders and Velcro too
  129.  
  130.         The "?" call to the .bin uses the technique recommended by
  131. Microsoft to detect the presence of a mouse driver.  This is a totally
  132. stupid technique.  It first looks for "00 00 00 00" as the vector for
  133. int 33h, the mouse interrupt.  To be sure, if this vector were null
  134. there would be a serious problem, because the processor would jump to
  135. location 0000:0000 and try to execute as code the address found there.
  136. A crash would almost surely result.  However, one of the first things
  137. the computer does on power up is place a jump to an IRET in each interrupt
  138. vector so that calling one that is not used will not be fatal.  If there
  139. is in fact a set of four nulls as the int 33h vector, there's a lot more
  140. wrong than the absence of a mouse and it is unlikely that this defense
  141. will salvage the situation.
  142.  
  143.         The presence of an IRET at the location pointed to by the int 33h
  144. vector does show there is no mouse driver.  On the other hand, calling one
  145. of the int 33h functions such as 0 to reset the mouse will, if the vector
  146. points to an IRET, return with nothing changed, after which the calling
  147. program will know there is no driver.  Accordingly, checking for an IRET
  148. is essentially a waste of time.
  149.  
  150.         If you have an assembler, be brave and remove this garbage from
  151. the program.
  152.  
  153.                             dBASE Programming
  154.  
  155.         In programs, it is often desirable to check for a mouse and turn it
  156. on if it exists with one operation.  From the dot prompt, this is disastrous
  157. because after the program turns on the mouse, so will dBASE, leaving mouse
  158. turds.  Consequently, this program is written so that when the bin is called
  159. with "?", it should not set the mouse on.
  160.  
  161.         Unfortunately, the state of the mouse is hard to predict.  I think,
  162. but do not know for sure, that calling this bin with "?", then with "-",
  163. and finally with "+" will always turn on the mouse and its cursor without
  164. leaving mouse droppings.  Assistance of any volunteer "beta testers" in
  165. figuring out how to do this properly is welcomed.
  166.  
  167.         If the mouse is disabled with '-', enable it again with '+' and
  168. the cursor will reappear in the same place it disappeared from.  If you want
  169. to start it over in the center of the screen after a cal